package z.http.bean;

import android.text.TextUtils;
import z.utils.LogUtils;

public class Image {
	private long id = -1;
	private String url;
	private String name;
	private String totalName;
	private String type;
	private String path;
	private String host;

	public Image(String imageUrl) {
		try {
			if (!TextUtils.isEmpty(imageUrl)) {
				this.url = imageUrl;
				int firstIndex = imageUrl.indexOf("/", 7);
				int secondIndex = imageUrl.lastIndexOf("/");

				this.host = imageUrl.substring(0, firstIndex);
				this.path = imageUrl.substring(firstIndex, secondIndex + 1);

				this.totalName = imageUrl.substring(secondIndex + 1);

				int lastIndex = totalName.lastIndexOf(".");
				if (lastIndex > 0) {
					this.name = totalName.substring(0, lastIndex);
					this.type = totalName.substring(lastIndex + 1);
				} else {
					this.name = totalName;
					this.type = "";
				}
			}
		} catch (Exception e) {
			LogUtils.exception(e);
		}
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTotalName() {
		return totalName;
	}

	public void setTotalName(String totalName) {
		this.totalName = totalName;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getHost() {
		return host;
	}

	public void setHost(String host) {
		this.host = host;
	}

}
